package com.garlicts.framework.crawler.executor;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.garlicts.framework.crawler.registry.ServiceDiscovery;
import com.garlicts.framework.crawler.registry.ServiceRegistry;
import com.garlicts.framework.crawler.registry.ZookeeperServiceRegistry;

@Configuration
public class ExecutorConfig {

	@Value("${zkAddress}")
	private String zkAddress;
	
	@Value("${executorName}")
	private String executorName;
	
	@Value("${serviceAddress}")
	private String serviceAddress;
	
	@Bean
	public ServiceRegistry getServiceRegistry() {
		
		return new ZookeeperServiceRegistry(zkAddress);
		
	}
	
	@Bean
	public ExecutorServer getExecutorServer() {
		
		ServiceRegistry serviceRegistry = getServiceRegistry();
		
		return new ExecutorServer(executorName, serviceAddress, serviceRegistry);
		
	}
	
}
